<template>
	<view class="content">
		<view class="walletTop">
			<view class="walletcont">
				<view class="walletTitle">我的佣金</view>
				<view class="walletmoney">
					<view class="sign iconfont">&#xe604;</view>
					<view class="money">{{userInfo.brokeragePrice}}</view>
				</view>
				<view class="wallbot">
					<view class="wallbot_fl">已提现：<text class="iconfont sign">&#xe604;</text> {{userInfo.exPrice}}</view>
					<view class="wallrule" @click="getRules">
						<view>佣金规则</view>
						<image class="rulrs" src="https://taobaoke-paimai.oss-cn-beijing.aliyuncs.com/rule.png" mode=""></image>
					</view>
				</view>
				
				<image class="withdraw" src="https://taobaoke-paimai.oss-cn-beijing.aliyuncs.com/withdraw.png" mode="" @click="getWithdraw"></image>
			</view>
			<!-- 提现 -->
			
			<view class="brokerage">
				<!-- <view class="brokerage_list">
					<view class="broMoney">&#xe604;{{userInfo.receivedPrice}}</view>
					<view class="broker_detail">
						<view class="">已收佣金</view>
						<view class="iconfont ">&#xe601;</view>
					</view>
				</view>
				<view class="brokerage_list">
					<view class="broMoney">&#xe604;{{userInfo.uncollectedPrice}}</view>
					<view class="broker_detail">
						<view class="">待收佣金</view>
						<view class="iconfont ">&#xe601;</view>
					</view>
				</view> -->
				
				<view class="brokerage_group" @click="goReceived">
					<view class="brokerage_name">已收佣金</view>
					<view class="brokerage_fr">
						<view class="brokerage_price"> <text class="iconfont sign">&#xe604;</text> {{userInfo.receivedPrice}}</view>
						<view class="iconfont iconb">&#xe601;</view>
					</view>
				</view>
				
				
			</view>
			
		</view>
		<view class="detailgroup">
			<view class="detail_fixed">
				<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback" :height="600">
					<view class="detail_list" v-for="(item,index) in list" :key="index" @click="goDetail(item)">
						<view class="detail_fl">
							<image class="userAvatar" :src="item.avatar" mode=""></image>
							<view class="brouser_info">
								<view class="brouser_name ellipsis">{{item.nickname}}</view>
								<view class="broNum">队员：{{item.juniorNum}}人</view>
							</view>
						</view>
						<view class="detail_fr">
							<view class="bropay"><text class="iconfont sign">&#xe604;</text>{{item.brokeragePrice}}</view>
							<view class="iconfont broIcon">&#xe601;</view>
						</view>
					</view>
				</mescroll-body>
			</view>
			
		</view>
		
		
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				rechargeList:[],
				downOption: {
					auto: true //是否在初始化后,自动执行downCallback; 默认true
				},
				upOption: {
					auto: true, // 不自动加载
					// page: {
					// 	num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
					// 	size: 10 // 每页数据的数量
					// },
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty: {
						tip: '~ 空空如也 ~', // 提示
						btnText: '刷新',
						// 列表第一页无任何数据时,显示的空布局
						// use : 是否启用
						// icon : 空布局的图标路径 (支持网络路径)
						// tip : 提示文本
						// btnText : 按钮文本
						// fixed : 是否使用定位,默认false; 配置fixed为true,以下的top和zIndex才生效 (transform会使fixed失效,所以最终还是会降级为absolute)
						// top : fixed定位的top值 (完整的单位值,如"100rpx", "10%";)
						// zIndex : fixed定位z-index值
					},
					textNoMore: "--我也是有底线的--" //没有更多数据的提示文本
				},
				userInfo:{},
				list:[]
			}
		},
		onLoad() {
			this.getCommission();
			let that = this;
			uni.$on('update', function (data) {
				that.getCommission();
			})
		},
		methods: {
			// 提现规则  (弹窗)
			getRules: function () {
				uni.navigateTo({
					url: '../../login/potocol/potocol?type=3',
				});
			},
			downCallback(){
				this.mescroll.resetUpScroll(); //调用加载
			},
			upCallback(page) {
				console.log(page)
				let that = this;
				that.api.getUserBrokrrage({
					page:page.num,
					limit:page.size
				}).then(res => {
					console.log(res)
					let curPageData =res.data.juniorUserData.records;
					// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
					let curPageLen = curPageData.length;
					// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
					let totalPage = res.data.juniorUserData.pages;
					//设置列表数据
					setTimeout(() => { // 模拟效果
						if (page.num == 1) this.list = []; //如果是第一页需手动置空列表
						this.list = this.list.concat(curPageData); //追加新数据
						console.log(this.list,"-----");
						// 请求成功,隐藏加载状态
						//方法一(推荐): 后台接口有返回列表的总页数 totalPage
						this.mescroll.endByPage(curPageLen, totalPage);
					}, 500)
					
				})
				
			},
			// 提现
			getWithdraw: function () {
				uni.navigateTo({
					url: '../rechargePayment/userWithdraw/userWithdraw?depositType=2',
				});
			},
			// 我的佣金
			getCommission: function () {
				this.api.getUserBrokrrage().then(res => {
					console.log(res)
					this.userInfo = res.data.userEarning
				})
			},
			// 已收佣金
			goReceived: function () {
				uni.navigateTo({
					url: 'received/received',
				});
			},
			// 他人详情
			goDetail: function (item) {
				uni.navigateTo({
					url: 'receivedTeam/receivedTeam?uId=' + item.uid,
				});
			}
			
			
			
		}
	}
</script>

<style lang="less">
	page {
		width: 100%;
		box-sizing: border-box;
		letter-spacing: 3rpx;
		font-family: 'PingFang SC';
		background: #F5F5F5;
		// padding: 20rpx 40rpx;
		font-size: 30rpx;
		color: #140005;
	}
	.content {
		width: 100%;
		box-sizing: border-box;
	}
	.walletTop {
		width: 100%;
		box-sizing: border-box;
		position: relative;
		padding: 16rpx 39rpx;
		background: #FFFFFF;
		margin-bottom: 20rpx;
		.walletcont {
			width: 100%;
			height: 310rpx;
			box-sizing: border-box;
			display: flex;
			flex-flow: column;
			justify-content: space-between;
			background: url(https://taobaoke-paimai.oss-cn-beijing.aliyuncs.com/commision.png) no-repeat;
			background-size: 100%;
			border-radius: 16rpx;
			padding: 60rpx 40rpx 20rpx 40rpx;
			position: relative;
			.walletTitle {
				width: 100%;
				box-sizing: border-box;
				line-height: 44rpx;
				color: #FFFFFF;
			}
			.walletmoney {
				width: 100%;
				box-sizing: border-box;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				font-size: 80rpx;
				color: #FFFFFF;
				.sign {
					font-size: 40rpx;
					padding-top: 20rpx;
					color: #FFDA71;
				}
			}
			.wallbot {
				width: 100%;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 24rpx;
				color: #FFFFFF;
				.wallrule {
					display: flex;
					justify-content: flex-end;
					align-items: center;
					.rulrs {
						width: 24rpx;
						height: 24rpx;
						margin-left: 5rpx;
					}
				}
				.sign {
					color: #FFDA71;
				}
				
			}
			.withdraw {
				width: 140rpx;
				height: 79rpx;
				position: absolute;
				top: 0;
				right: -10rpx;
				bottom: 0;
				margin: auto;
				z-index: 30;
			}
		
		}
		.withdraw {
			width: 140rpx;
			height: 79rpx;
			position: absolute;
			top: 0;
			right: 29rpx;
			bottom: 0;
			margin: auto;
			z-index: 30;
		}
		.brokerage {
			width: 100%;
			box-sizing: border-box;
			display: flex;
			justify-content: space-around;
			align-items: center;
			font-size: 36rpx;
			color: #212121;
			// padding: 16rpx 39rpx 0 39rpx;
			padding-top: 16rpx;
			.brokerage_list {
				width: 50%;
				box-sizing: border-box;
				text-align: center;
				.broker_detail {
					width: 100%;
					box-sizing: border-box;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 24rpx;
					color: #666666;
					line-height: 40rpx;
				}
			}
			.brokerage_group {
				width: 100%;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;
				line-height: 60rpx;
				font-size: 36rpx;
				color: #212121;
				.brokerage_name {
					font-size: 30rpx;
				}
				.brokerage_fr {
					display: flex;
					justify-content: flex-end;
					align-items: center;
					.iconb {
						color: #666666;
						font-size: 28rpx;
					}
					.sign {
						color: #FFDA71;
					}
				}
				
			}
			
		}
	}
	
	.detailgroup {
		width: 100%;
		box-sizing: border-box;
		padding: 0 39rpx;
		background: #FFFFFF;
		.detail_fixed {
			width: 100%;
			box-sizing: border-box;
			overflow-y: scroll;
			.detail_list {
				width: 100%;
				box-sizing: border-box;
				padding: 35rpx 0;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.detail_fl {
					width: 75%;
					box-sizing: border-box;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					font-size: 30rpx;
					color: #212121;
					.userAvatar {
						width: 64rpx;
						height: 64rpx;
						border-radius: 50%;
					}
					.brouser_info {
						width: calc(100% - 64rpx);
						box-sizing: border-box;
						padding-left: 20rpx;
						display: flex;
						flex-flow: column;
						justify-content: space-between;
						.broNum {
							font-size: 24rpx;
							color: #666666;
						}
						
					}
				}
				.detail_fr {
					width: 25%;
					box-sizing: border-box;
					display: flex;
					justify-content: flex-end;
					align-items: center;
					font-size: 30rpx;
					color: #E42221;
					line-height: 70rpx;
					.broIcon {
						font-size: 28rpx;
						color: #999999;
					}
					.sign {
						color: #FFDA71;
					}
				}
				
			}
			
		}
		
	}
	
	
	
	
	

</style>
